/**
 */
package mvc_generator.mVCGenerator.impl;

import java.util.Collection;

import mvc_generator.mVCGenerator.ExpressionValidator;
import mvc_generator.mVCGenerator.MVCGeneratorPackage;
import mvc_generator.mVCGenerator.Page;
import mvc_generator.mVCGenerator.Validator;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Validator</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mvc_generator.mVCGenerator.impl.ValidatorImpl#getValidatorName <em>Validator Name</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.ValidatorImpl#getPageOnSuccess <em>Page On Success</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.ValidatorImpl#getExpressionValidators <em>Expression Validators</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ValidatorImpl extends MinimalEObjectImpl.Container implements Validator
{
  /**
   * The default value of the '{@link #getValidatorName() <em>Validator Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValidatorName()
   * @generated
   * @ordered
   */
  protected static final String VALIDATOR_NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getValidatorName() <em>Validator Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValidatorName()
   * @generated
   * @ordered
   */
  protected String validatorName = VALIDATOR_NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getPageOnSuccess() <em>Page On Success</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPageOnSuccess()
   * @generated
   * @ordered
   */
  protected Page pageOnSuccess;

  /**
   * The cached value of the '{@link #getExpressionValidators() <em>Expression Validators</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExpressionValidators()
   * @generated
   * @ordered
   */
  protected EList<ExpressionValidator> expressionValidators;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ValidatorImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MVCGeneratorPackage.Literals.VALIDATOR;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getValidatorName()
  {
    return validatorName;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValidatorName(String newValidatorName)
  {
    String oldValidatorName = validatorName;
    validatorName = newValidatorName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.VALIDATOR__VALIDATOR_NAME, oldValidatorName, validatorName));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Page getPageOnSuccess()
  {
    if (pageOnSuccess != null && pageOnSuccess.eIsProxy())
    {
      InternalEObject oldPageOnSuccess = (InternalEObject)pageOnSuccess;
      pageOnSuccess = (Page)eResolveProxy(oldPageOnSuccess);
      if (pageOnSuccess != oldPageOnSuccess)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, MVCGeneratorPackage.VALIDATOR__PAGE_ON_SUCCESS, oldPageOnSuccess, pageOnSuccess));
      }
    }
    return pageOnSuccess;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Page basicGetPageOnSuccess()
  {
    return pageOnSuccess;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPageOnSuccess(Page newPageOnSuccess)
  {
    Page oldPageOnSuccess = pageOnSuccess;
    pageOnSuccess = newPageOnSuccess;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.VALIDATOR__PAGE_ON_SUCCESS, oldPageOnSuccess, pageOnSuccess));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ExpressionValidator> getExpressionValidators()
  {
    if (expressionValidators == null)
    {
      expressionValidators = new EObjectContainmentEList<ExpressionValidator>(ExpressionValidator.class, this, MVCGeneratorPackage.VALIDATOR__EXPRESSION_VALIDATORS);
    }
    return expressionValidators;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.VALIDATOR__EXPRESSION_VALIDATORS:
        return ((InternalEList<?>)getExpressionValidators()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.VALIDATOR__VALIDATOR_NAME:
        return getValidatorName();
      case MVCGeneratorPackage.VALIDATOR__PAGE_ON_SUCCESS:
        if (resolve) return getPageOnSuccess();
        return basicGetPageOnSuccess();
      case MVCGeneratorPackage.VALIDATOR__EXPRESSION_VALIDATORS:
        return getExpressionValidators();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.VALIDATOR__VALIDATOR_NAME:
        setValidatorName((String)newValue);
        return;
      case MVCGeneratorPackage.VALIDATOR__PAGE_ON_SUCCESS:
        setPageOnSuccess((Page)newValue);
        return;
      case MVCGeneratorPackage.VALIDATOR__EXPRESSION_VALIDATORS:
        getExpressionValidators().clear();
        getExpressionValidators().addAll((Collection<? extends ExpressionValidator>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.VALIDATOR__VALIDATOR_NAME:
        setValidatorName(VALIDATOR_NAME_EDEFAULT);
        return;
      case MVCGeneratorPackage.VALIDATOR__PAGE_ON_SUCCESS:
        setPageOnSuccess((Page)null);
        return;
      case MVCGeneratorPackage.VALIDATOR__EXPRESSION_VALIDATORS:
        getExpressionValidators().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.VALIDATOR__VALIDATOR_NAME:
        return VALIDATOR_NAME_EDEFAULT == null ? validatorName != null : !VALIDATOR_NAME_EDEFAULT.equals(validatorName);
      case MVCGeneratorPackage.VALIDATOR__PAGE_ON_SUCCESS:
        return pageOnSuccess != null;
      case MVCGeneratorPackage.VALIDATOR__EXPRESSION_VALIDATORS:
        return expressionValidators != null && !expressionValidators.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (validatorName: ");
    result.append(validatorName);
    result.append(')');
    return result.toString();
  }

} //ValidatorImpl
